package com.itcast.cn.login.mapper;

import com.itcast.cn.login.pojo.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * <p>接口描述</p>
 *
 * @author hyatt 2022/1/18 16:43
 * @version 1.0
 */
public interface UserMapper {

    /**
     * 根据用户名和密码查询用户
     * @param username 用户名
     * @param password 密码
     * @return 用户
     */
    @Select("select * from tb_user where 1=1 and username= #{username} and password=#{password}")
    User select(@Param("username") String username,@Param("password") String password);

    /**
     * 根据用户名查询用户
     * @param username 用户名
     * @return 用户
     */
    @Select("select * from tb_user where 1=1 and username=#{username}")
    User selectByUserName(String username);

    /**
     * 创建用户
     * @param user 用户
     */
    @Insert("insert into tb_user values(null, #{username}, #{password})")
    void add(User user);
}
